package cn.tedu.straw.search.controller;

import cn.tedu.straw.search.service.IQuestionService;
import cn.tedu.straw.search.vo.QuestionSearchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es/question")
public class QuestionController {
    @Autowired
    IQuestionService questionService;
    // http://localhost:8200/es/question/search?keyword=haha
    @GetMapping("/search")
    public Page<QuestionSearchVO> search(String keyword, Integer page) {
        if (page == null || page < 1) {
            page = 1;
        }
        return questionService.search(keyword, page);
    }
}
